<?php 
unset($_GET['ok']);
$create_app_id=Yii::app()->params['create_app_id'];
$cs=Yii::app()->clientScript;
$cs->registerScript('schedule_to_appointment',<<<END
$(".schedule_to_appointment").click(
function(){
	var exists=true;
	var tab=parent.tab;
	var n = tab.getComponent('$create_app_id');
	if(n){
		exists=confirm('添加派车单窗口已存在，是否关闭已有窗口进行添加?');
		if(exists) tab.remove('$create_app_id');
	}
	if(exists){
		n = tab.add({'id':'$create_app_id','title':'添加派车单',	closable:true,height:'100px',
            html: "<iframe class='$create_app_id' scrolling='auto' frameborder='0' width='100%' height='100%' src='?r=truck_appointment/create&sid="+$(this).attr('id')+"'></iframe>"});
        tab.setActiveTab(n);  
	}
}
);
END
);
?>
<?php if($search):?>
<h2>查询作业计划单</h2>
<?php else:?>
<h2>修改作业计划单</h2>
<?php endif?>
<?php echo CHtml::beginForm(array($search?'search':'admin'),'post');?>
<table  style="margin: 0 auto;"  width="1220">
<tr><td>
	货主发货人：<input type="text" name="keys[consignor.name]" size="7" value="<?php echo isset($_GET['keys']['consignor.name'])?$_GET['keys']['consignor.name']:'';?>"/>
	起运地：<input type="text" name="keys[path.loading_place]" size="7" value="<?php echo isset($_GET['keys']['path.loading_place'])?$_GET['keys']['path.loading_place']:'';?>"/>
	到达地：<input type="text" name="keys[path.pod_place]" size="7" value="<?php echo isset($_GET['keys']['path.pod_place'])?$_GET['keys']['path.pod_place']:'';?>"/>
	到达时间：从<input type="text" id="keys[s_date]" name="keys[s_date]" size="7" value="<?php echo isset($_GET['keys']['s_date'])?$_GET['keys']['s_date']:'';?>"/>
	<?php $this->widget('application.extensions.calendar.SCalendar',array('inputField'=>'keys[s_date]','ifFormat'=>'%Y-%m-%d'));?>
	至<input type="text" id="keys[e_date]" name="keys[e_date]" size="7" value="<?php echo isset($_GET['keys']['e_date'])?$_GET['keys']['e_date']:'';?>"/>
	<?php $this->widget('application.extensions.calendar.SCalendar',array('inputField'=>'keys[e_date]','ifFormat'=>'%Y-%m-%d'));?>
	货物种类：<input type="text" name="keys[gkind.name]" size="7" value="<?php echo isset($_GET['keys']['gkind.name'])?$_GET['keys']['gkind.name']:'';?>"/><br/>
	所属区域：&nbsp;&nbsp;&nbsp;<input type="text" name="keys[users.region]" size="7" value="<?php echo isset($_GET['keys']['users.region'])?$_GET['keys']['users.region']:'';?>"/>
	模糊查询：<input type="radio" name="keys[blur]" value="1" checked/>是  
	<input type="radio" name="keys[blur]" value="0" <?php echo isset($_GET['keys']['blur'])&&$_GET['keys']['blur']==0?'checked':'';?>/>否 
	<input type="submit" value="搜索"/>
</td></tr></table>
<?php echo CHtml::endForm();?>
<table class="dataGrid" width="1220">
  <thead>
  <tr>
    <th width="100"><?php echo $sort->link('consignor_name'); ?></th>
    <th width="100"><?php echo $sort->link('deliver_place'); ?></th>
    <th width="100"><?php echo $sort->link('arrival_place'); ?></th>
    <th width="70"><?php echo $sort->link('mileage'); ?></th>
    <th width="130"><?php echo $sort->link('deliver_time'); ?></th>
    <th width="130"><?php echo $sort->link('arrival_time'); ?></th>
    <th width="160"><?php echo $sort->link('goods_name'); ?></th>
    <th width="70"><?php echo $sort->link('unit_price'); ?></th>
    <th width="70"><?php echo $sort->link('amount'); ?></th>
    <th width="80"><?php echo $sort->link('freight_charge'); ?></th>
    <th width="80"><?php echo $sort->link('user_region'); ?></th>
	<?php if(!$search):?><th width="130">操作</th><?php endif ?>
  </tr>
  </thead>
  <tbody>
<?php foreach($models as $n=>$model): ?>
  <tr class="<?php echo $n%2?'even':'odd';?>">
   <?php 
    	$url=array('show','id'=>$model->id)+$_GET;//把所有参数包括页码、查询参数传入显示信息页面
    	$url['ret']=$search?'search':'admin';
    ?>
    <td><?php echo CHtml::link($model->consignor_name,$url); ?></td>
    <td><?php echo CHtml::encode($model->deliver_place); ?></td>
    <td><?php echo CHtml::encode($model->arrival_place); ?></td>
    <td><?php echo CHtml::encode($model->mileage); ?></td>
    <td><?php echo CHtml::encode($model->deliver_time); ?></td>
    <td><?php echo CHtml::encode($model->arrival_time); ?></td>
    <td><?php echo CHtml::encode($model->goods_name); ?></td>
    <td><?php echo CHtml::encode($model->unit_price); ?></td>
    <td><?php echo CHtml::encode($model->amount); ?></td>
    <td><?php echo CHtml::encode($model->freight_charge); ?></td>
    <td><?php echo CHtml::encode($model->user_region); ?></td>
    <?php if(!$search):?>
    <td>
      <?php echo CHtml::link('修改',array('update','id'=>$model->id)+$_GET); ?>
      <?php echo CHtml::link('删除',array('delete','id'=>$model->id)+$_GET,array('confirm'=>"确定要删除货主(收货人)：{$model->consignor_name} 的作业计划单吗？")); ?>
      <a class="schedule_to_appointment" id="<?php echo $model->id;?>" href="#">导入派车单</a>
	</td>
	<?php endif ?>
  </tr>
<?php endforeach; ?>
  </tbody>
</table>
<br/>
<?php $this->widget('CLinkPager',array('pages'=>$pages,'htmlOptions'=>array('style'=>'width:1220px;'))); ?>